<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('rd_organize_user', function (Blueprint $table) {
            $table->comment('工区账号公司关联表');
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id')->nullable()->comment('用户id');
            $table->unsignedBigInteger('enterprise_id')->nullable()->comment('企业id');
            $table->string('wechat_openid', 64)->comment('微信openid，用于微信登录');
            $table->json('extra_data')->nullable()->comment('额外数据，存储各平台特有的用户信息');
            $table->string('department', 64)->comment('部门')->nullable();
            $table->string('position', 64)->comment('职位')->nullable();
            $table->timestamps();
            $table->authorBy();
            $table->string('remark')->comment('备注')->default('');
            $table->unique(['wechat_openid'], 'uk_wechat_openid');
        });
    }
    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('rd_organize_user');
    }
};